﻿using System;
using System.Collections.Generic;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;
using NetTopologySuite.Index;

namespace NetTopologySuite.Simplify
{
	public class LineSegmentVisitor : IItemVisitor<LineSegment>
	{
		public LineSegmentVisitor(LineSegment querySeg)
		{
			this._querySeg = querySeg;
		}

		public void VisitItem(LineSegment item)
		{
			if (Envelope.Intersects(item.P0, item.P1, this._querySeg.P0, this._querySeg.P1))
			{
				this._items.Add(item);
			}
		}

		public IList<LineSegment> Items
		{
			get
			{
				return this._items;
			}
		}

		private readonly LineSegment _querySeg;

		private readonly IList<LineSegment> _items = new List<LineSegment>();
	}
}
